import sys
from flask import Flask
import os
from dotenv import load_dotenv
from api.glasses_routes import glasses_bp
from api.server_routes import server_bp

# 加载.env文件中的环境变量
load_dotenv()

app = Flask(__name__)

# 注册蓝图
app.register_blueprint(glasses_bp, url_prefix='/glasses')
app.register_blueprint(server_bp, url_prefix='/api')

# 使用环境变量
debug_mode = os.getenv('DEBUG', 'False').lower() == 'true'
port = int(os.getenv('PORT', 8000))

env = os.getenv('APP_ENV', 'production')

if __name__ == '__main__':
    app.run(
        debug=debug_mode,  # 控制调试模式
        port=port,         # 设置端口
        host='0.0.0.0'
    )